<template>
    <div class="search-input-group">
        <el-input type="text" v-model="keyword" placeholder="搜索您喜欢的...">
            <template #prefix>
                <el-icon>
                    <Search />
                </el-icon>
            </template>
            <!-- <template #append>
                <div class="search-btn" @click="onSearch">
                    <el-icon size="16" color="#fff">
                        <Search />
                    </el-icon>
                    搜索
                </div>
            </template> -->
        </el-input>
    </div>
</template>
<script setup>
import { Search } from "@element-plus/icons-vue";
import { ref } from "vue";

const emits = defineEmits(["search"]);
const keyword = ref("");

const onSearch = () => {
    emits("search", keyword.value);
};

watch(keyword, () => {
    onSearch();
});

defineExpose({
    clear() {
        keyword.value = "";
    }
});
</script>
<style lang="scss" scoped>
.search-input-group {
    :deep(.el-input) {
        .el-input-group__append {
            width: 80px;
            padding: 0;
            box-shadow: none;
            background-color: #5085fb !important;
            color: #fff;
            user-select: none;
            cursor: pointer;

            i {
                margin-right: 3px;
            }
        }
    }

    .search-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
</style>
